//
//  UIBarButtonItem_Category.swift
//  DSWeiBo
//
//  Created by H on 16/4/25.
//  Copyright © 2016年 Mr.Lin. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    class  func createBarButtonItem(imageName:String,target:AnyObject?,action:Selector) ->UIBarButtonItem {
        
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), forState: .Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        btn.sizeToFit()

        let barButton = UIBarButtonItem(customView:btn)
        return barButton
    }

}